package com.sxj.corejava.code09_集合.Map;

import java.util.Enumeration;
import java.util.Properties;
import java.util.Set;

/**
 * @author 石小俊
 * 2024年07月25日 13:38
 */
public class Test05_Properties {

    public static void main(String[] args) {
        Properties properties = new Properties();
        //properties.put("1","admin");
        properties.setProperty("1", "admin");
        properties.setProperty("2", "alice");
        properties.setProperty("3", "jack");
        //properties.setProperty(null,null);
        System.out.println(properties);

        System.out.println(properties.getProperty("1"));
        System.out.println(properties.getProperty("2"));

        Set<Object> keys = properties.keySet();
        for (Object key : keys) {
            System.out.println("key:" + key + ",value:" + properties.getProperty((String) key));
        }

        Enumeration<Object> values = properties.elements();
        while (values.hasMoreElements()) {
            System.out.println("value:" + values.nextElement());
        }

    }

}
